<?php

class SessionUtility extends PrspLibrary{
	
	public function initial(){}
	
	public function clearValues( $pluginId=null ){
		if( $pluginId==null ){
			$pluginId = Runtime::getPluginId();
		}
		if( session_is_registered( $pluginId ) ){
			session_unregister( $pluginId );
		}
	}

	public function delKey( $key, $pluginId=null ){
		if( $pluginId==null ){
			$pluginId = Runtime::getPluginId();
		}
		if( isset( $_SERVER[$pluginId][$key] ) ){
			unset($_SERVER[$pluginId][$key]);
		}
	}
	
	public function setValue( $key, $value, $pluginId=null ){
		if( $pluginId==null ){
			$pluginId = Runtime::getPluginId();
		}
		if (! session_is_registered ( $pluginId )) {
			session_register ( $pluginId );
		}
		$_SESSION [$pluginId][$key] = $value;
	}

	public function getValue( $key, $pluginId=null ){
		if( $pluginId==null ){
			$pluginId = Runtime::getPluginId();
		}
		if( session_is_registered( $pluginId ) && isset($_SESSION[$pluginId][$key]) ){
			return $_SESSION[$pluginId][$key];
		}else{
			return null;
		}
	}
	
	public function getValues( $pluginId=null ){
		if( $pluginId==null ){
			$pluginId = Runtime::getPluginId();
		}
		if( session_is_registered( $pluginId ) ){
			return $_SESSION[$pluginId];
		}else{
			return null;
		}
	}

}
?>